package com.zhuss.idea.idea;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.idea.idea.CreateIdeaBo;
import com.zhuss.bean.bo.idea.idea.DeleteIdeaBo;
import com.zhuss.bean.bo.idea.idea.UpdateIdeaBo;
import com.zhuss.bean.bo.idea.idea.wechat.CollectIdeaBo;
import com.zhuss.bean.bo.idea.idea.wechat.DelTopicIdeaBo;
import com.zhuss.bean.bo.idea.idea.wechat.ForwardIdeaBo;
import com.zhuss.bean.bo.idea.idea.wechat.ThumbIdeaBo;
import com.zhuss.bean.bo.idea.idea.wechat.TopicIdeaBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.WpsException;

/**
 * idea操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-05 15:59
 *
 */
@Component("ideaOperateService")
public class IdeaOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("ideaCreate")
	private Processor<Object, CreateIdeaBo> ideaCreate;
	
	@Autowired
	@Qualifier("ideaUpdate")
	private Processor<Object, UpdateIdeaBo> ideaUpdate;
	
	@Autowired
	@Qualifier("ideaDelete")
	private Processor<Object, DeleteIdeaBo> ideaDelete;
	
	@Autowired
	@Qualifier("ideaThumb")
	private Processor<Object, ThumbIdeaBo> ideaThumb;
	
	@Autowired
	@Qualifier("ideaCollect")
	private Processor<Object, CollectIdeaBo> ideaCollect;
	
	@Autowired
	@Qualifier("ideaForward")
	private Processor<Object, ForwardIdeaBo> ideaForward;
	
	@Autowired
	@Qualifier("ideaTopic")
	private Processor<Object, TopicIdeaBo> ideaTopic;
	
	@Autowired
	@Qualifier("ideaDelThumb")
	private Processor<Object, ThumbIdeaBo> ideaDelThumb;
	
	@Autowired
	@Qualifier("ideaDelCollect")
	private Processor<Object, CollectIdeaBo> ideaDelCollect;
	
	@Autowired
	@Qualifier("ideaDelForward")
	private Processor<Object, ForwardIdeaBo> ideaDelForward;
	
	@Autowired
	@Qualifier("ideaDelTopic")
	private Processor<Object, DelTopicIdeaBo> ideaDelTopic;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws WpsException {
		
		CreateIdeaBo bo = (CreateIdeaBo) param;
		
		ideaCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws WpsException {
    	
		UpdateIdeaBo bo = (UpdateIdeaBo) param;
		
		ideaUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws WpsException {
		
		DeleteIdeaBo bo = (DeleteIdeaBo) param;
		
		ideaDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void thumb(Object param) throws WpsException {
		
		ThumbIdeaBo bo = (ThumbIdeaBo) param;
		
		ideaThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void collect(Object param) throws WpsException {
		
		CollectIdeaBo bo = (CollectIdeaBo) param;
		
		ideaCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void forward(Object param) throws WpsException {
		
		ForwardIdeaBo bo = (ForwardIdeaBo) param;
		
		ideaForward.process(bo);
		
		return null;
	}
	
	/**
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void topic(Object param) throws WpsException {
		
		TopicIdeaBo bo = (TopicIdeaBo) param;
		
		ideaTopic.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 点赞
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delThumb(Object param) throws WpsException {
		
		ThumbIdeaBo bo = (ThumbIdeaBo) param;
		
		ideaDelThumb.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 收藏
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delCollect(Object param) throws WpsException {
		
		CollectIdeaBo bo = (CollectIdeaBo) param;
		
		ideaDelCollect.process(bo);
		
		return null;
	}
	
	/**
	 * 取消
	 * 转发
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delForward(Object param) throws WpsException {
		
		ForwardIdeaBo bo = (ForwardIdeaBo) param;
		
		ideaDelForward.process(bo);
		
		return null;
	}
	
	/**
	 * 删
	 * 评论
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void delTopic(Object param) throws WpsException {
		
		DelTopicIdeaBo bo = (DelTopicIdeaBo) param;
		
		ideaDelTopic.process(bo);
		
		return null;
	}
	
}

